package com.zpark.controller;

import com.zpark.pojo.User;
import com.zpark.servicer.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: UserController
 * @Description:
 * @author: RZS
 * @date: 2023/4/11  17:19
 */
//@Controller
@RequestMapping("/user")
//@ResponseBody  // 类上的@ResponseBody表示当前控制器的所有方法返回值类型均为json格式数据
@RestController // @RestController相当于@Controller与@ResponseBody两个注解组合
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/find_all.do")
    // @ResponseBody // 表示当前方法返回值为json格式数据，不经过视图解析器
    public List<User> findUserAll(){
        return userService.findAll();
    }

    /**
     * @RequestBody注解：声明请求参数必须为json格式数据
     * @return
     */
    @RequestMapping("/add.do")
    // @ResponseBody
    public String addUser(@RequestBody String param){

//        User user = new User(id, uname, pwd);

//        userService.addUser(user);

        return param;
    }
}
